package com.examples.sorting;

public class SelectionSort {
	public static void selectionSort(int[] matrix) {
		int pos = -1;
		
		for(int i = 0; i < matrix.length; i++) {
			pos = i;
			for(int j = i+1 ;j < matrix.length; j++)
				if(matrix[j]<matrix[pos])
					pos = j;				
			int temp = matrix[pos];
				matrix[pos] = matrix[i];
				matrix[i] = temp;
		}
	}
	public static void main(String[] args) {
		// Selection Sort

				int[] matS = GeneratePrintArray.generateRandomArray(10);
				//int[] matS = {10,2,3,7,5};
				System.out.print("\n\nSelection Sort  \t");
				GeneratePrintArray.printArray(matS);
				selectionSort(matS);
				
				System.out.print("\nSelection Sorted   ");
				GeneratePrintArray.printArray(matS);		
	}
}

